package monster.comm.action;

import javax.servlet.http.HttpSession;

import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;

import monster.comm.log.ILog;
import monster.comm.log.LogService;
import monster.comm.util.ReturnVO;
import monster.comm.util.SessionBean;
import monster.comm.util.SysConstant;

/**
 * dwr基类,所有子类方法访问前必须调用isLogin方法判断
 * 是否登录，登录成功返回1，否返回0
 * @author wanghong 2012-12-25 BaseDwr.java
 * 
 */
public class BaseDwr {
	private static ILog log = LogService.getLog(BaseJsonAction.class);
	private String logined = "0";// 是否登录	
	
	protected String getLogined() {
		return logined;
	}


	private HttpSession session;

	public BaseDwr() {
		WebContext webContext = WebContextFactory.get();
		session = webContext.getSession(false);
	}
    /**
     * 如果登录放回1，否则返回0
     * @return String 
     */
	protected String isLogin() {
		// String logined="0";//是否登录
		Object obj = (session!=null?session.getAttribute(SysConstant.SESSION_NAME):null);
		if (obj == null) {// 没有登录			
			logined = "0";
		} else {
			logined = "1";
		}
		return logined;
	}

	/**
	 * 返回sessionbean
	 * 
	 * @return SessionBean
	 */
	protected SessionBean getUserSession() {
		return (SessionBean)(session!=null?session.getAttribute(SysConstant.SESSION_NAME):null);
	}
}
